<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<form id="ligerForm">
				<div class="fieldset1 tabel_col clearFix">
	
			<div class="fieldBox col_100">
						<div style="width: 100%; ">
		<table style="BORDER-COLLAPSE: collapse;margin-bottom:20px" borderColor=#ECECEC height=40 cellPadding=1 width="100%" align=center border=1> 
							
				<thead>
								<tr style="background:#E7FEF4;">
									<th class="tbLabel" rowspan="2"></th>
									<th class="tbLabel" style="text-align: center;" rowspan="2">机构名称</th>
									<th class="tbLabel" style="text-align: center;" rowspan="2">业务线</th>
									<th class="tbLabel" style="text-align: center;" rowspan="2">是否服务</th>
									<th class="tbLabel" style="text-align: center;" rowspan="2">优先级</th>
									<th class="tbLabel" style="text-align: center;" rowspan="2"></th>
									<th class="tbLabel" style="text-align: center;" colspan="3">机构限额信息</th>
								</tr>
								<tr style="background:#E7FEF4">
									<th class="tbLabel" style="text-align: center;">项目类型</th>
									<th class="tbLabel" style="text-align: center;">融资额上限（万）</th>
									<th class="tbLabel" style="text-align: center;">设备数上限（台）</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${insList}" var="item" varStatus="status">
								<tr>
									<td rowspan="${item.rowspan}" style="text-align: center; height:10px;">${status.index+1}</td>
									<td rowspan="${item.rowspan}" style="text-align: center; height:10px;">${item.fundRasInsNm}</td>
									<td rowspan="${item.rowspan}" style="text-align: center; height:10px;">
										${item.bussinessLineNm}
									</td>
									<td rowspan="${item.rowspan}" style="text-align: center; height:10px;">
										<c:if test="${item.isService == '1'}">是</c:if>
										<c:if test="${item.isService == '0'}">否</c:if>
									</td>
									
									
									<td rowspan="${item.rowspan}" style="text-align: center; height:10px;">
									${item.zgNum}
									</td>
									<td rowspan="${item.rowspan}" style="text-align: center; height:10px;">
									<a style="color:#013D79 " href="javascript:openList('${item.id}');">相似机构列表</a>
									</td>
									
									<td style="text-align: center;">${item.prjTyp}</td>
									<td style="text-align: center;">${item.insLimAmt}</td>
									<td style="text-align: center;">${item.insLimMum}</td>
								</tr>
								
									<c:forEach items="${item.fundRasInsLimList}" var="fundRasInsLim" begin="1">
									<tr>
										<td style="text-align: center;">${fundRasInsLim.PRJ_TYP}</td>
										<td style="text-align: center;">${fundRasInsLim.INS_LIM_AMT_}</td>
										<td style="text-align: center;">${fundRasInsLim.INS_LIM_NUM_}</td>
									</tr>
									</c:forEach>
								</c:forEach>
							
		</table>
		</div>
		</div>
		</div>
		<!-- <div class="clearFix" style="text-align:center">

			<span id="cr_bsc_info_add_btn_id" class="sq-button sq-button-round" onclick="save();">保存 </span>
		</div> -->
	</form>
	</div>
	</div>
	<script type="text/javascript">
	
	function openList(insId){
		var timestamp=new Date().getTime();
		var param = '<%=path%>/rfbase/fundInsSimilarInfo/toListPage.do?mainFundInsId=' + insId ;
		Add_navTab('similarityDegree'+timestamp,'相似机构列表',param, function () {
			//grid.reload();
		});
	}
	
		function changeNum(index){
			if($("#isService"+index).val()=='1' ){
				$("#zgNum"+index).attr("disabled",false);
			}else{
				$("#zgNum"+index).attr("disabled","disabled");
			}
			
		}
		
		//保存
		function save(){
			//校验优先级不能重复
			for(var i=0;i<${insSize};i++){
				if($("#isService"+i).val()=='1' ){
						if($("#zgNum"+i).val()==''){
							alert("请填写优先级!");
							$("#zgNum"+i).focus();
							return;
						}
						var re=/^\d*\.{0,1}\d*$/;
						if(re.exec($("#zgNum"+i).val())==null){
							alert("请输入数字格式!");
							$("#zgNum"+i).focus();
							return;
						}
				}
				for(var j=i+1;j<${insSize};j++){
						if($("#isService"+j).val()=='1' && $("#zgNum"+j).val()==$("#zgNum"+i).val()){
							alert("优先级不可重复，请核查");
							$("#zgNum"+j).val("");
							$("#zgNum"+j).focus();
							return;
						}
				}
			}
			var ids="";
			var isServices="";
			var zgNums="";
			for(var i=0;i<${insSize};i++){
				ids=ids+$("#zgNum"+i).attr("sid")+",";
				zgNums=zgNums+$("#zgNum"+i).val()+",";
				isServices=isServices+$("#isService"+i).val()+",";
			}
            var data = {
            		ids:ids,
            		zgNums:zgNums,
            		isServices:isServices	
            };
           var url="<%=path%>/rfbase/fribaseinfo/modifyNums.do";
           
			AjaxUtils.ajaxPost(url, data, addCallback);
		}

		//新增回调
		function addCallback(msg) {
			if (msg.success == 1) {
				UIUtils.alertSuccess(msg.info);
				location.reload();
				
			} else {
				UIUtils.alertError(msg.info);
			}
		}
		
		

	</script>

</body>
</html>
